﻿using System;
using System.Collections;
using System.Linq;
using System.Text;
using WhiteFox.DAlessio.Patterns.UI.MVC;
using WhiteFox.DAlessio.Agenda.Domain.Repository;
using WhiteFox.DAlessio.Agenda.Domain.Model;
using System.Collections.Generic;

namespace WhiteFox.DAlessio.Agenda.View.Controllers
{
    public class TelefoneControler : Controller<TelefoneRepository>
    {
        public IEnumerable<Telefone> Listar()
        {
            return Domain.Repository.GetAll();
        }
        public Telefone Obter(int id)
        {
            return Domain.Repository.GetByID(id);
        }
        public void Salvar(Telefone telefone)
        {
            Domain.Repository.Save(telefone);
        }

        public IEnumerable<Telefone> ListarPorContato(Contato contato)
        {
            foreach(var tmp in Domain.Repository.GetAll())
            {
                if(tmp.Contato_Id == contato.Id)
                    yield return tmp;
            }
        }

    }
}
